/*
 * Exception.cpp
 *
 *  Created on: 01/12/2008
 *      Author: fernando
 */

#include "Exception.h"
#include <sstream>

using std::stringstream;

namespace core {

Exception::Exception() throw() :
	_id("core::Exception"), _what(NULL), _cause(NULL) {
}

Exception::Exception(const char* id) throw() :
	_id(id), _what(NULL), _cause(NULL) {
}

Exception::Exception(const char* id, const char* what) throw() :
	_id(id), _what(what), _cause(NULL) {
}

Exception::Exception(const char* id, const char* what, const char* cause) throw() :
	_id(id), _what(what), _cause(cause) {
}

Exception::~Exception() throw() {
}

const char* Exception::what() const throw() {
	stringstream ss;
	ss << "(" << _id << ")";
	if (_what != NULL)
		ss << ": " << _what;
	if (_cause != NULL)
		ss << ": Caused by: " << _cause;
	return ss.str().c_str();
}

}
